﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Netduino4Fun.DesktopAssistant.Windows.Plugins.Log
{
    /// <summary>
    /// Interaction logic for Log.xaml
    /// </summary>
    public partial class Log : UserControl
    {
        public Log()
        {
            InitializeComponent();
        }



        public string LogData
        {
            get { return (string)GetValue(LogProperty); }
            set { SetValue(LogProperty, value); }
        }

        public static readonly DependencyProperty LogProperty =
            DependencyProperty.Register("LogData", typeof(string), typeof(Log), new FrameworkPropertyMetadata(string.Empty));

        private void UserControl_Initialized(object sender, EventArgs e)
        {
            Netduino.Netduino.Instance.LineReceived += new Netduino.LineReceivedEventHandler(Instance_LineReceived);
        }

        void Instance_LineReceived(string line)
        {
            Dispatcher.Invoke(
                new Action(
                    () =>
                    {
                        string ligne = line + "\n";
                        LogData += ligne;

                    }
                ));
                
            
        }


    }
}
